CC = g++ -Wall -std=c++17
RELEASE = 0
UNICODE = 0  
LOADBIN = -L ../StorageModule_Database -L ../StorageModule_Config -L ../StorageModule_Session -L ../StorageModule_APIHelp -L ../StorageModule_Protocol -L ../XEngine_ThirdPart/jsoncpp                                       
LIB = -lXEngine_BaseLib -lXEngine_Algorithm -lXEngine_Core -lXEngine_ManagePool -lXEngine_OPenSsl -lXEngine_ProcFile -lXEngine_SystemApi -lHelpComponents_XLog -lHelpComponents_Packets -lRfcComponents_HttpServer -lNetHelp_APIHelp \
      -lStorageModule_Database -lStorageModule_Config -lStorageModule_Session -lStorageModule_APIHelp -lStorageModule_Protocol \
	  -ljsoncpp
LIBEX = -ldl -lpthread
LOADSO = -Wl,-rpath=./,--disable-new-dtags
LIBINCLUDE = StorageApp_Config.o StorageApp_Download.o StorageApp_Network.o StorageApp_Center.o StorageApp_UPLoader.o Storage_TaskPass.o Storage_TaskManage.o Storage_TaskP2p.o XEngine_StorageApp.o

ifeq ($(shell uname),Darwin)
	LOADSO = 
else
	LOADBIN += -L /usr/local/lib/XEngine_Release/XEngine_BaseLib -L /usr/local/lib/XEngine_Release/XEngine_Core -L /usr/local/lib/XEngine_Release/XEngine_SystemSdk -L /usr/local/lib/XEngine_Release/XEngine_HelpComponents -L /usr/local/lib/XEngine_Release/XEngine_RfcComponents -L /usr/local/lib/XEngine_Release/XEngine_NetHelp 
endif

ifeq ($(RELEASE),1)
FLAGS = -c -O2 
DEBUG = 
else
FLAGS = -c
DEBUG = -g
endif

ifeq ($(UNICODE),1)
UNICODE = -D _UNICODE
else
UNICODE = 
endif

all:$(LIBINCLUDE)
	$(CC) $(DEBUG) $(LIBINCLUDE) -o XEngine_XStorageApp $(LOADBIN) $(LIB) $(LIBEX) $(LOADSO)
  
StorageApp_Config.o:./StorageApp_Config.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./StorageApp_Config.cpp 
StorageApp_Download.o:./StorageApp_Download.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./StorageApp_Download.cpp
StorageApp_Network.o:./StorageApp_Network.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./StorageApp_Network.cpp 
StorageApp_Center.o:./StorageApp_Center.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./StorageApp_Center.cpp
StorageApp_UPLoader.o:./StorageApp_UPLoader.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./StorageApp_UPLoader.cpp

Storage_TaskPass.o:./Storage_APPTask/Storage_TaskPass.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./Storage_APPTask/Storage_TaskPass.cpp
Storage_TaskManage.o:./Storage_APPTask/Storage_TaskManage.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./Storage_APPTask/Storage_TaskManage.cpp
Storage_TaskP2p.o:./Storage_APPTask/Storage_TaskP2p.cpp
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./Storage_APPTask/Storage_TaskP2p.cpp
					
XEngine_StorageApp.o:./XEngine_StorageApp.cpp             
	$(CC) $(DEBUG) $(FLAGS) $(UNICODE) ./XEngine_StorageApp.cpp   


InstallAll:InstallApp
InstallApp:./XEngine_XStorageApp
	cp -f ./XEngine_XStorageApp ../../XEngine_Release/XEngine_XStorageApp
	
CleanAll:CleanObj CleanMk 
CleanObj:                                              
	rm *.o
CleanMk:                                  
	rm XEngine_XStorageApp
